/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.thinkgem.jeesite.modules.order.dao;

import java.math.BigInteger;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import com.thinkgem.jeesite.common.persistence.BaseDao;
import com.thinkgem.jeesite.common.persistence.BaseDaoImpl;
import com.thinkgem.jeesite.modules.order.entity.QuHuoDan;

/**
 * 取货单DAO接口
 * 
 * @author 李忠
 * @version 2013-07-28
 */
public interface QuHuoDanDao extends QuHuoDanDaoCustom, CrudRepository<QuHuoDan, Long> {

	@Modifying
	@Query("update QuHuoDan set delFlag='" + QuHuoDan.DEL_FLAG_DELETE + "' where id = ?1")
	public int deleteById(Long id);
	@Modifying
	@Query("update QuHuoDan set delFlag='4' where id in ?1")
	public int zhengbao(List<Long> ids);


	@Query(value = "select count(1) from order_quHuoDan where DATE_FORMAT(create_date, '%Y-%m-%d') = CURRENT_DATE", nativeQuery = true)
	public BigInteger countCurrenteDate();

}

/**
 * DAO自定义接口
 * 
 * @author 李忠
 */
interface QuHuoDanDaoCustom extends BaseDao<QuHuoDan> {
	public int fenpai(Long qhdUserId, String ids);

}

/**
 * DAO自定义接口实现
 * 
 * @author 李忠
 */
@Component
class QuHuoDanDaoImpl extends BaseDaoImpl<QuHuoDan> implements QuHuoDanDaoCustom {

	@Override
	public int fenpai(Long qhdUserId, String ids) {
		String sql = "update order_quHuoDan set qhr_user_id=" + qhdUserId + ", del_flag = '2' where id in (" + ids
				+ ")";
		return this.getEntityManager().createNativeQuery(sql).executeUpdate();
	}

}
